package com.xquant.transaction_management_system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xquant.transaction_management_system.model.PO.FinancialInstruments;
import com.xquant.transaction_management_system.model.PO.TransactionControl;
import com.xquant.transaction_management_system.model.VO.TransactionControlSearchVo;
import com.xquant.transaction_management_system.service.TransactionControlService;
import com.xquant.transaction_management_system.utils.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;

@Api("金融控制控制层")
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class TransactionControlController {
    @Autowired
    private TransactionControlService transactionControlService;
    @PostMapping("/getByQuery/{page}/{limit}")
    public Result getByQuery(@PathVariable Long page,
            @PathVariable Long limit,
            @RequestBody TransactionControlSearchVo transactionControlSearchVo){
        Page<TransactionControl> pageParam = new Page<>();
        pageParam.setCurrent(page-1);
        pageParam.setSize(limit);
        IPage<TransactionControl> pageModel = transactionControlService.selectPage(pageParam,transactionControlSearchVo);
        return Result.ok(pageModel);
    }
    @GetMapping("/getByPage/{page}/{limit}")
    public Result getByPage(@PathVariable Long page,
                             @PathVariable Long limit){
        Page<TransactionControl> pageParam = new Page<>();
        pageParam.setCurrent(page-1);
        pageParam.setSize(limit);
        IPage<TransactionControl> pageModel = transactionControlService.selectByPage(pageParam);
        return Result.ok(pageModel);
    }
}
